

package controllers;
import models.*;
import db.*;
import java.util.ArrayList;





public class EmployeeController {

    private boolean EmployeeCreated;
    private boolean EmployeeUpdated;
    private boolean EmployeeRemoved;

     private EmployeeInterface empdb = new EmployeeDB();
    /** Creates a new instance of CtrEmp */


    public EmployeeController() {

    }

    public ArrayList findAllemployee()
    {
        EmployeeInterface dbEmp = new EmployeeDB();
        ArrayList allEmp = new ArrayList();
        allEmp =dbEmp.getAllEmployees(false);
        return allEmp;
        
    }

     public Employee newEmployee (int id, String name, String username)
    {
        EmployeeCreated = false;
        Employee employee = new Employee(name, username);
        empdb.addEmployee(employee);

        return employee;

    }

    public Employee findByname(String name)
    {
        EmployeeInterface dbEmp = new EmployeeDB();
        return dbEmp.searchEmployeeName(name, true);
    }
     public Employee findByID(String username)
    {
        EmployeeInterface dbEmp = new EmployeeDB();
        return dbEmp.searchEmployeeUsername(username, true);
    }
      public Employee findByUsername(int id)
    {
        EmployeeInterface dbEmp = new EmployeeDB();
        return dbEmp.searchEmployeeId( id, true);
    }
      public int updateEmp(String name, int id, String username)
      {
          EmployeeInterface dbEmp = new EmployeeDB();
          models.Employee emp = new Employee();
          emp.setName(name);
          emp.setId(id);
          emp.setUsername(username);
          return  dbEmp.updateEmployee(emp);


      }


}
